// Package auth pkg/auth/password.go
package auth

import (
	"golang.org/x/crypto/bcrypt"
)

// EncryptPassword 使用bcrypt加密密码
func EncryptPassword(password string) (string, error) {
	bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
	return string(bytes), err
}

// VerifyPassword 验证密码是否正确
func VerifyPassword(password, hashedPassword string) bool {
	err := bcrypt.CompareHashAndPassword([]byte(hashedPassword), []byte(password))
	return err == nil
}
